package com.systar.activity.events;

import java.nio.ByteBuffer;

import com.systar.activity.monitor.ActivitySource;

public abstract class AbstractActivityEvent implements IActivityEvent
{
	private ActivitySource source;

	protected AbstractActivityEvent()
	{
		// nop
	}

	public String getSourceName()
	{
		return source.getName();
	}

	@Override
	public ActivitySource getSource()
	{
		return source;
	}

	public void setSource(ActivitySource source)
	{
		this.source = source;
	}

	@Override
	public String getMessage()
	{
		return getSourceName();
	}
	
	@Override
	public String marshal()
	{
		return source.marshal() + "&" + getType() + "=";
	}

	@Override
	public void marshal(ByteBuffer data)
	{
		// nothing by default
	}

	@Override
    public IActivityEvent clone()
	{
		try
		{
			return (IActivityEvent)super.clone();
		}
		catch (CloneNotSupportedException e)
		{
			e.printStackTrace();
			return null;
		}
	}
	
}
